package com.xgpro.mapper.talentintroduction;


import com.xgpro.domain.talentintroduction.entity.Recruitment;
import com.xgpro.domain.talentintroduction.vo.RecBack;
import com.xgpro.domain.talentintroduction.vo.RecFront;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import tk.mybatis.mapper.common.Mapper;


import java.util.List;

/**
 * @author tx
 * @version 1.0
 * @date 2019/8/18 20:05
 */
public interface RecruitmentMapper extends Mapper<Recruitment> {
   /**
     * 应聘信息批量删除
     * @param ids
     * @return
     */
    @Update("<script>" +
            " update t_recruitment  set flag=2 " +
            " <where>"+
            " id in " +
            " <foreach collection='list' index='index' item='id'  open='(' separator=',' close=')'>" +
            " #{id}" +
            " </foreach>" +
            " </where>" +
            "</script>")
    Integer deleteRecruitmentByList(List<Integer> ids);

    /**
     * 查询招聘信息
     * @param frontPC
     * @return
     */
    @Select("<script>" +
            " select t_recruitment.id as id,t_recruitment.name as name,t_recruitment.kind as kind,t_deptment.name as deptName,t_recruitment.f_salary as fSalary,t_recruitment.e_salary as eSalary,t_recruitment.recommended as recommended " +
            " from t_recruitment left join  t_user on t_recruitment.user_id = t_user.id left join t_deptment on t_recruitment.dept_id=t_deptment.id " +
            "<where>" +
            "  t_recruitment.flag=1 and t_recruitment.user_id is not null " +
            " <if test=\"frontPC.name != null and frontPC.name!='' \"> " +
            "  and t_recruitment.name like CONCAT('%',#{frontPC.name},'%')" +
            " </if>" +
            " <if test=\"frontPC.deptName != null and frontPC.deptName!='' \"> " +
            "  and t_deptment.name like CONCAT('%',#{frontPC.deptName},'%')" +
            " </if>" +
            " <if test=\"frontPC.kind != null and frontPC.kind!='' or frontPC.kind == 0 \"> " +
            "  and t_recruitment.kind =#{frontPC.kind}" +
            " </if>" +
            "</where>" +
            " group by t_recruitment.update_time DESC" +
            "</script>")
    List<RecBack> selectRecruitmentByRecFront(@Param("frontPC") RecFront frontPC);
}
